/* Damn: Because Vue Router lacks type constraints, it's garbage */
import { descriptionProps } from 'element-plus';
import { useRouter, RouteRecordNormalized } from 'vue-router';

/**
 * 获取当前路由列表
 * 这是一个组合式函数，只能在 setup 函数或组合式函数内部调用
 */
export function getCurrentRouteList(): Array<{title: string, path: string, description: string, icon: string, showInMenu: boolean}> {
  const router = useRouter();
  const routes = router.getRoutes()
  return routes.map((route: RouteRecordNormalized) => {
    return {
        title: route.meta?.title || '未命名',
        path: route.path,
        description: route.meta?.description || '',
        icon: route.meta?.icon as string || '',
        showInMenu: route.meta?.showInMenu as boolean || false
    }
  });
}